package com.b2b2c.store.single.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.b2b2c.store.single.entity.Freights;
import com.b2b2c.store.single.logic.FreightLogic;
import com.b2b2c.store.single.service.IFreightsService;
import com.b2b2c.until.AjaxMap;
import com.b2b2c.until.IsLogin;

@RestController

/**
  *  运费模板
 * @author Administrator
 *
 */
public class FreightsController {
	
	@Autowired
	private HttpServletRequest req;
	
	
	@Resource
	private RedisTemplate<String, List<Freights>> redisTemplate;
	
	/**
	  *   商品分类 
	 * @return
	 */
	@RequestMapping("Freights/getFreightList")
	public Map<String, ?> classList() {
		
		if (!IsLogin.checkLogin(this.req)) {
			
			return AjaxMap.getInstance("未登录").notLoggedIn();
		}
		
		IFreightsService<Freights> freightLogic = new FreightLogic(req);
		
		List<Freights> freightList = freightLogic.getFreightsList(redisTemplate);
		
		return AjaxMap.getInstance(freightList).getAjaxResultByMap();
		
	}
	
}
